package logic;

import map.Map;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;

import controllers.ObjectController;
import controllers.PlayerController;
import frame.Frame;

public class GameLogic {
	
	PlayerController playerController;
	Map map;
	Frame frame;
	ObjectController objectController;
	
	public GameLogic()
	{
		playerController = new PlayerController();
		map = new Map();
		frame = new Frame(playerController);
		objectController = new ObjectController(playerController);
	}

	public void render(GameContainer container, Graphics g) throws SlickException
	{	
		map.render(container, g);
		objectController.render(container, g);
		frame.render(container, g);
	}
	public void update(GameContainer container, int delta) throws SlickException
	{		
		objectController.update(container, delta);
		objectController.addSkill(frame.getFlag());
		
		frame.update(container, delta);	
		frame.setLife(objectController.getLife());
		frame.updateLife(objectController.getMaxLife(), objectController.getActLife());
	}
}
